﻿if (typeof Axis == "undefined") Axis = {};
if (typeof Axis.View == "undefined") Axis.View = {};
if (typeof Axis.View.ReceiveGift == "undefined") Axis.View.ReceiveGift = {};
Axis.View.Banner.List = {
    Init: function () {
        this.GetList();
    },
    GetList: function () {
        var thisObj = this;
        if (typeof CateID == 'undefined') var CateID = 0;
        var pData = '{' + $.string.Format('"CateID":{0}', CateID) + '}';
        $.ajax({
            url: '../Banner/Service/BannerService.asmx/GetListReceiveGift',
            type: 'POST',
            data: pData,
            cache: false,
            async: false,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (pData, textStatus, jqXHR) {
                var data = eval("(" + pData.d + ")");
                thisObj.BuildList(data);

            },
            beforeSend: function (jqXHR, settings) {
            },
            error: function (jqXHR, textStatus, errorThrown) {
            },
            complete: function (XMLHttpRequest, textStatus) {
            }
        });

    },
    BuildList: function (data) {
        var objThis = this;
        var pattern = '<div class="ReceiveGiftItem">'
                +'<img src="{0}" onclick=\"ViewBanner({1})">'
                +'<div class="item-desc">   {2}<br>'
                +'</div>'
            +'</div>';
        
        var htmlContent = "";
        $.each(data, function (index, item) {
            htmlContent += $.string.Format(pattern,  item.Image,item.ID,item.Description);
        });
        $("#SliderReceiveGift").html(htmlContent);

        objThis.CreateAtimate();
    },
    CreateAtimate: function () {
        $('#SliderReceiveGift').cycle({
            fx: 'custom',
            cssBefore: {
                left: 115,
                top: 115,
                width: 0,
                height: 0,
                opacity: 1,
                display: 'block'
            },
            animOut: {
                opacity: 0
            },
            animIn: {
                left: 0,
                top: 0,
                width: 200,
                height: 200
            },
            cssAfter: {
                zIndex: 0
            },
            delay: -3000
        });
    }

}

$(function () {
    Axis.View.Banner.List.Init();
})


 